<template>
  <div class="game_container">

    <div class="timer">
      <p>
        {{ time }}
      </p>
    </div>

  </div>
</template>

<script>
export default {
  name: 'App',
  data () {
    return {
      c: 0,
      totalTime: 3,
      t: '',
      type: this.$route.query.type,
      time: '',

    };
  },

  mounted () {
    this.timedCount();

  },
  methods: {

    timedCount: function () {
      var that = this
      var t = setTimeout(function () {
        this.time = (this.totalTime - this.c) == 0 ? "答题开始" : (this.totalTime - this.c)
        if ((this.totalTime - this.c) == 0) {
          this.stopCount();
          this.c = 0;
        } else {
          that.timedCount();
        }
      }, 1000)
    },

    stopCount: function () {
      setTimeout(function () {
        this.$router.push({ name: 'throughGameGoing', query: { type: this.$route.query.type } })
      }, 2000)
    }

  }
}
</script>
